#!/bin/bash
# Author: fanyongfeng
# 0 9 * * * /bin/bash /root/script/maven_log_backup.sh &>> /backup/maven_log_backup/backup.log

YESTERDAY=$(date  +"%Y-%m-%d" -d  "-1 days")
BACKUP_DIR="/backup/maven_log_backup"
LOG_DIR="/data/nexus3/log/audit"

mkdir -p ${BACKUP_DIR}

\cp -p ${LOG_DIR}/audit-${YESTERDAY}.log.gz ${BACKUP_DIR}

find ${BACKUP_DIR} -type f -mtime +180 -name "audit-*.log.gz" | xargs -r -n 10 rm -f